package com.learn.thread;

/**
 * 静态代理
 * 找女友
 * 可以自己找
 * 可以找婚介所找
 * 通过婚介所找的话，婚介所作为代理，你把你的诉求告诉你婚介所就行
 */
public class DemoStaticProxy {
    public static void main(String[] args) {
        new MarriageAgency(new Yourself("我的诉求是：一个肤白貌美大长腿的姑娘"),"mark").findLove();
    }
}

/**
 * 找女友
 */
interface FindGirlFriend {
    void findLove();
}
class Yourself implements FindGirlFriend{
    private String appeal;

    public Yourself() {
    }

    public Yourself(String appeal) {
        this.appeal = appeal;
    }

    @Override
    public void findLove() {
        System.out.println(appeal);
    }
}

/**
 * 婚介所
 */
class MarriageAgency implements FindGirlFriend{
    private FindGirlFriend target;
    private String name;
    public MarriageAgency(FindGirlFriend target){
        this.target = target;
    }
    public MarriageAgency(FindGirlFriend target,String name){
        this.target = target;
        this.name=name;
    }
    @Override
    public void findLove() {
        System.out.println("给用户"+name+"开始找女朋友");
        target.findLove();
        System.out.println("给用户"+name+"找女朋友结束");
    }
}